#include <REGX52.h>
#include "Timer.h"
#include "LCD1602.h"

//秒 分钟 小时
unsigned char sec = 55, min = 59, hour = 23;

//定时器0中断函数模板
void Timer0_Rountine(void) interrupt 1
{
	static unsigned int timeCount = 0;
	TH0 = 64535 / 256;
	TL0 = 64535 % 256;
	timeCount++;
	if(timeCount >= 1000)
	{
		timeCount = 0;
		sec++;
		if(sec >= 60)
		{
			sec = 0;
			min++;
			if(min >= 60)
			{
				min = 0;
				hour++;
				if(hour >= 24)
					hour = 0;
			}
		}
	}
}

void main()
{
	LCD_Init();//LCD初始化
	Timer0Init();//定时器初始化
	LCD_ShowString(1, 1, "Clock:");
	LCD_ShowString(2, 1, "  :  :  ");
    while(1)
    {
        LCD_ShowNum(2, 1, hour, 2);
		LCD_ShowNum(2, 4, min, 2);
		LCD_ShowNum(2, 7, sec, 2);
    }
}